package com.huijinhui.wlmtsys.controller;


import com.huijinhui.wlmtsys.pojo.dtos.PageDTO;
import com.huijinhui.wlmtsys.pojo.dtos.ResponseResult;
import com.huijinhui.wlmtsys.pojo.entity.*;
import com.huijinhui.wlmtsys.service.EmployService;
import com.huijinhui.wlmtsys.service.NewsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "admin----招聘接口")
@RestController
@RequestMapping("/employ")
@RequiredArgsConstructor
@Slf4j
public class EmployController {

    @Autowired
    private EmployService employService;

    @Operation(summary = "admin---新增招聘信息接口")
    @PostMapping("/add")
    public void addEmploy( @RequestBody Employ employ) {
        log.info("新增招聘信息接口");
        employService.saveEmploy(employ);
    }


    @Operation(summary = "admin---删除招聘信息接口")
    @DeleteMapping("/delete/{id}")
    public void deleteEmploy(@PathVariable("id") Integer id) {
        log.info("删除招聘信息接口");
        employService.deleteEmploy(id);
    }

    @Operation(summary = "admin---更新招聘信息接口")
    @PutMapping("/update")
    public void updateEmploy(@RequestBody Employ employ) {
        log.info("更新招聘信息接口");
        employService.updateEmploy(employ);
    }


    @Operation(summary = "admin---分页 获取招聘信息接口")
    @GetMapping("/page")
    public PageDTO<Employ> queryNewsPage(PageQuery query){
        log.info("分页 获取招聘信息接口");
        return employService.queryEmployPage(query);
    }

    @Operation(summary = "招聘查询接口")
    @GetMapping("/list/{lables}")
    public ResponseResult getEmployList(@PathVariable("lables") Integer lables) {
        log.info("招聘查询接口");
        List<Employ> list = employService.getEmployList(lables);
        return ResponseResult.okResult(list);
    }
}

